home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / General / GCC 1.37.1r15 / Machines / convex.md < prev    next >
Text File  |  1990-03-14  |  35KB  |  1,267 lines

  1. ;;- Machine description for GNU compiler
  2. ;;- Convex Version
  3. ;;   Copyright (C) 1989 Free Software Foundation, Inc.
  4.  
  5. ;; This file is part of GNU CC.
  6.  
  7. ;; GNU CC is free software; you can redistribute it and/or modify
  8. ;; it under the terms of the GNU General Public License as published by
  9. ;; the Free Software Foundation; either version 1, or (at your option)
  10. ;; any later version.
  11.  
  12. ;; GNU CC is distributed in the hope that it will be useful,
  13. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. ;; GNU General Public License for more details.
  16.  
  17. ;; You should have received a copy of the GNU General Public License
  18. ;; along with GNU CC; see the file COPYING.  If not, write to
  19. ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  20.  
  21.  
  22. ;;- Instruction patterns.  When multiple patterns apply,
  23. ;;- the first one in the file is chosen.
  24. ;;-
  25. ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
  26. ;;-
  27. ;;- cpp macro #define NOTICE_UPDATE_CC in file tm.h handles condition code
  28. ;;- updates for most instructions.
  29.  
  30. ;; Put tstsi first among test insns so it matches a CONST_INT operand.
  31.  
  32. (define_insn "tstsi"
  33.   [(set (cc0)
  34.     (match_operand:SI 0 "register_operand" "r"))]
  35.   ""
  36.   "* return set_cmp (operands[0], const0_rtx, 'w');")
  37.  
  38. (define_insn "tsthi"
  39.   [(set (cc0)
  40.     (match_operand:HI 0 "register_operand" "r"))]
  41.   ""
  42.   "* return set_cmp (operands[0], const0_rtx, 'h');")
  43.  
  44. (define_expand "tstqi"
  45.   [(set (match_dup 1)
  46.     (sign_extend:SI (match_operand:QI 0 "register_operand" "r")))
  47.    (set (cc0)
  48.     (match_dup 1))]
  49.   ""
  50.   "operands[1] = gen_reg_rtx (SImode);")
  51.  
  52. (define_insn "tstdi"
  53.   [(set (cc0)
  54.     (match_operand:DI 0 "register_operand" "d"))
  55.    (clobber (reg:DI 1))]
  56.   ""
  57.   "*
  58. {
  59.   output_asm_insn (\"ld.l #0,s1\");
  60.   return set_cmp (operands[0], gen_rtx (REG, DImode, 1), 'l');
  61. }")
  62.  
  63. (define_expand "tstdf"
  64.   [(set (cc0)
  65.     (compare (match_operand:DF 0 "register_operand" "d")
  66.          (match_dup 1)))]
  67.   ""
  68.   "operands[1] = force_reg (DFmode, dconst0_rtx);")
  69.  
  70. (define_insn "tstsf"
  71.   [(set (cc0)
  72.     (match_operand:SF 0 "register_operand" "d"))]
  73.   ""
  74.   "* return set_cmp (operands[0], fconst0_rtx, 's');")
  75.  
  76. ;; Put cmpsi first among compare insns so it matches two CONST_INT operands.
  77.  
  78. (define_insn "cmpsi"
  79.   [(set (cc0)
  80.     (compare (match_operand:SI 0 "nonmemory_operand" "d,a,i,r")
  81.          (match_operand:SI 1 "nonmemory_operand" "d,a,r,i")))]
  82.   ""
  83.   "* return set_cmp (operands[0], operands[1], 'w');")
  84.  
  85. (define_insn "cmphi"
  86.   [(set (cc0)
  87.     (compare (match_operand:HI 0 "nonmemory_operand" "d,a,r,i")
  88.          (match_operand:HI 1 "nonmemory_operand" "d,a,i,r")))]
  89.   ""
  90.   "* return set_cmp (operands[0], operands[1], 'h');")
  91.  
  92. (define_insn ""
  93.   [(set (cc0)
  94.     (compare (sign_extend:SI (match_operand:QI 0 "register_operand" "d"))
  95.          (sign_extend:SI (match_operand:QI 1 "register_operand" "d"))))]
  96.   ""
  97.   "* return set_cmp (operands[0], operands[1], 'b');")
  98.  
  99. (define_insn "cmpdi"
  100.   [(set (cc0)
  101.     (compare (match_operand:DI 0 "register_operand" "d")
  102.          (match_operand:DI 1 "register_operand" "d")))]
  103.   ""
  104.   "* return set_cmp (operands[0], operands[1], 'l');")
  105.  
  106. (define_insn "cmpdf"
  107.   [(set (cc0)
  108.     (compare (match_operand:DF 0 "register_operand" "d")
  109.          (match_operand:DF 1 "register_operand" "d")))]
  110.   ""
  111.   "* return set_cmp (operands[0], operands[1], 'd');")
  112.  
  113. (define_insn "cmpsf"
  114.   [(set (cc0)
  115.     (compare (match_operand:SF 0 "nonmemory_operand" "dF,d")
  116.          (match_operand:SF 1 "nonmemory_operand" "d,F")))]
  117.   ""
  118.   "* return set_cmp (operands[0], operands[1], 's');")
  119.  
  120. (define_insn "movdf"
  121.   [(set (match_operand:DF 0 "general_operand" "=g,d")
  122.     (match_operand:DF 1 "general_operand" "d,gG"))]
  123.   ""
  124.   "*
  125. {
  126.   if (push_operand (operands[0], DFmode))
  127.     return \"psh.l %1\";
  128.   else if (GET_CODE (operands[0]) == MEM)
  129.     return \"st.l %1,%0\";
  130.   else if (GET_CODE (operands[1]) == REG)
  131.     return \"mov %1,%0\";
  132.   else if (GET_CODE (operands[1]) == CONST_DOUBLE && LD_D_P (operands[1]))
  133.     {
  134.       operands[1] = gen_rtx (CONST_INT, VOIDmode,
  135.                  const_double_high_int (operands[1]));
  136.       return \"ld.d %1,%0\";
  137.     }
  138.   else
  139.     return \"ld.l %1,%0\";
  140. }")
  141.  
  142. (define_insn "movsf"
  143.   [(set (match_operand:SF 0 "general_operand" "=g,d")
  144.     (match_operand:SF 1 "general_operand" "d,gF"))]
  145.   ""
  146.   "*
  147. {
  148.   if (push_operand (operands[0], SFmode))
  149.     return \"psh.w %1\";
  150.   else if (GET_CODE (operands[0]) == MEM)
  151.     return \"st.s %1,%0\";
  152.   else if (GET_CODE (operands[1]) == REG)
  153.     return \"mov.s %1,%0\";
  154.   else
  155.     return \"ld.s %1,%0\";
  156. }")
  157.  
  158. (define_insn "movdi"
  159.   [(set (match_operand:DI 0 "general_operand" "=g,d")
  160.     (match_operand:DI 1 "general_operand" "d,gG"))]
  161.   ""
  162.   "*
  163. {
  164.   if (push_operand (operands[0], DImode))
  165.     return \"psh.l %1\";
  166.   else if (GET_CODE (operands[0]) == MEM)
  167.     return \"st.l %1,%0\";
  168.   else if (GET_CODE (operands[1]) == REG)
  169.     return \"mov %1,%0\";
  170.   else if (GET_CODE (operands[1]) == CONST_DOUBLE && LD_D_P (operands[1]))
  171.     {
  172.       operands[1] = gen_rtx (CONST_INT, VOIDmode,
  173.                  const_double_high_int (operands[1]));
  174.       return \"ld.d %1,%0\";
  175.     }
  176.   else
  177.     return \"ld.l %1,%0\";
  178. }")
  179.  
  180. ;; Special case of movsi, needed to express A-reg preference.
  181.  
  182. (define_insn ""
  183.   [(set (match_operand:SI 0 "push_operand" "=<")
  184.     (plus:SI (match_operand:SI 1 "register_operand" "a")
  185.          (match_operand:SI 2 "immediate_operand" "i")))]
  186.   "operands[1] != stack_pointer_rtx"
  187.   "pshea %a2(%1)")
  188.  
  189. (define_insn "movsi"
  190.   [(set (match_operand:SI 0 "general_operand" "=g,r,<")
  191.     (match_operand:SI 1 "general_operand" "r,g,io"))]
  192.   ""
  193.   "*
  194.   if (push_operand (operands[0], SImode))
  195.     {
  196.       if (GET_CODE (operands[1]) == REG)
  197.     return \"psh.w %1\";
  198.       else
  199.         return \"pshea %a1\";
  200.     }
  201.   if (GET_CODE (operands[0]) == MEM)
  202.     return \"st.w %1,%0\";
  203.   if (GET_CODE (operands[1]) != REG)
  204.     return \"ld.w %1,%0\";
  205.   if (S_REG_P (operands[0]) && S_REG_P (operands[1]))
  206.     return \"mov.w %1,%0\";
  207.   return \"mov %1,%0\";
  208. }")
  209.  
  210. (define_insn "movhi"
  211.   [(set (match_operand:HI 0 "general_operand" "=g,r")
  212.     (match_operand:HI 1 "general_operand" "r,g"))]
  213.   ""
  214.   "*
  215. {
  216.   if (push_operand (operands[0], HImode))
  217.     abort ();
  218.   else if (GET_CODE (operands[0]) == MEM)
  219.     return \"st.h %1,%0\";
  220.   else if (GET_CODE (operands[1]) == REG) 
  221.     {
  222.       if (S_REG_P (operands[0]) && S_REG_P (operands[1]))
  223.     return \"mov.w %1,%0\";
  224.       else
  225.         return \"mov %1,%0\";
  226.     }
  227.   else if (GET_CODE (operands[1]) == CONST_INT)
  228.     return \"ld.w %1,%0\";
  229.   else
  230.     return \"ld.h %1,%0\";
  231. }")
  232.  
  233. (define_insn "movqi"
  234.   [(set (match_operand:QI 0 "general_operand" "=g,r")
  235.     (match_operand:QI 1 "general_operand" "r,g"))]
  236.   ""
  237.   "*
  238. {
  239.   if (push_operand (operands[0], QImode))
  240.     abort ();
  241.   else if (GET_CODE (operands[0]) == MEM)
  242.     return \"st.b %1,%0\";
  243.   else if (GET_CODE (operands[1]) == REG)
  244.     {
  245.       if (S_REG_P (operands[0]) && S_REG_P (operands[1]))
  246.     return \"mov.w %1,%0\";
  247.       else
  248.         return \"mov %1,%0\";
  249.     }
  250.   else if (GET_CODE (operands[1]) == CONST_INT)
  251.     return \"ld.w %1,%0\";
  252.   else
  253.     return \"ld.b %1,%0\";
  254. }")
  255.  
  256. ;; Extension and truncation insns.
  257. ;; Those for integer source operand
  258. ;; are ordered widest source type first.
  259.  
  260. (define_insn "truncsiqi2"
  261.   [(set (match_operand:QI 0 "register_operand" "=d,a")
  262.     (truncate:QI (match_operand:SI 1 "register_operand" "d,a")))]
  263.   ""
  264.   "cvtw.b %1,%0")
  265.  
  266. (define_insn "truncsihi2"
  267.   [(set (match_operand:HI 0 "register_operand" "=d,a")
  268.     (truncate:HI (match_operand:SI 1 "register_operand" "d,a")))]
  269.   ""
  270.   "cvtw.h %1,%0")
  271.  
  272. (define_insn "trunchiqi2"
  273.   [(set (match_operand:QI 0 "register_operand" "=r")
  274.     (truncate:QI (match_operand:HI 1 "register_operand" "0")))]
  275.   ""
  276.   "")
  277.  
  278. (define_insn "truncdisi2"
  279.   [(set (match_operand:SI 0 "register_operand" "=d")
  280.     (truncate:SI (match_operand:DI 1 "register_operand" "d")))]
  281.   ""
  282.   "cvtl.w %1,%0")
  283.  
  284. (define_insn "extendsidi2"
  285.   [(set (match_operand:DI 0 "register_operand" "=d")
  286.     (sign_extend:DI (match_operand:SI 1 "register_operand" "d")))]
  287.   ""
  288.   "cvtw.l %1,%0")
  289.  
  290. (define_insn "extendhisi2"
  291.   [(set (match_operand:SI 0 "register_operand" "=d,a")
  292.     (sign_extend:SI (match_operand:HI 1 "register_operand" "d,a")))]
  293.   ""
  294.   "cvth.w %1,%0")
  295.  
  296. (define_insn "extendqihi2"
  297.   [(set (match_operand:HI 0 "register_operand" "=d,a")
  298.     (sign_extend:HI (match_operand:QI 1 "register_operand" "d,a")))]
  299.   ""
  300.   "cvtb.w %1,%0")
  301.  
  302. (define_insn "extendqisi2"
  303.   [(set (match_operand:SI 0 "register_operand" "=d,a")
  304.     (sign_extend:SI (match_operand:QI 1 "register_operand" "d,a")))]
  305.   ""
  306.   "cvtb.w %1,%0")
  307.  
  308. (define_insn "extendsfdf2"
  309.   [(set (match_operand:DF 0 "register_operand" "=d")
  310.     (float_extend:DF (match_operand:SF 1 "register_operand" "d")))]
  311.   ""
  312.   "cvts.d %1,%0")
  313.  
  314. (define_insn "truncdfsf2"
  315.   [(set (match_operand:SF 0 "register_operand" "=d")
  316.     (float_truncate:SF (match_operand:DF 1 "register_operand" "d")))]
  317.   ""
  318.   "cvtd.s %1,%0")
  319.  
  320. (define_insn "zero_extendhisi2"
  321.   [(set (match_operand:SI 0 "register_operand" "=r")
  322.     (zero_extend:SI (match_operand:HI 1 "register_operand" "0")))]
  323.   ""
  324.   "and #0xffff,%0")
  325.  
  326. (define_insn "zero_extendqihi2"
  327.   [(set (match_operand:HI 0 "register_operand" "=r")
  328.     (zero_extend:HI (match_operand:QI 1 "register_operand" "0")))]
  329.   ""
  330.   "and #0xff,%0")
  331.  
  332. (define_insn "zero_extendqisi2"
  333.   [(set (match_operand:SI 0 "register_operand" "=r")
  334.     (zero_extend:SI (match_operand:QI 1 "register_operand" "0")))]
  335.   ""
  336.   "and #0xff,%0")
  337.  
  338. (define_insn "zero_extendsidi2"
  339.   [(set (match_operand:DI 0 "register_operand" "=d")
  340.     (zero_extend:DI (match_operand:SI 1 "register_operand" "0")))]
  341.   ""
  342.   "ld.u #0,%0")
  343.  
  344. ;; Fix-to-float conversion insns.
  345. ;; Note that the ones that start with SImode come first.
  346. ;; That is so that an operand that is a CONST_INT
  347. ;; (and therefore lacks a specific machine mode).
  348. ;; will be recognized as SImode (which is always valid)
  349. ;; rather than as QImode or HImode.
  350.  
  351. (define_insn "floatsisf2"
  352.   [(set (match_operand:SF 0 "register_operand" "=d")
  353.     (float:SF (match_operand:SI 1 "register_operand" "d")))]
  354.   ""
  355.   "cvtw.s %1,%0")
  356.  
  357. (define_insn "floatdisf2"
  358.   [(set (match_operand:SF 0 "register_operand" "=d")
  359.     (float:SF (match_operand:DI 1 "register_operand" "d")))]
  360.   ""
  361.   "cvtl.s %1,%0")
  362.  
  363. (define_insn "floatsidf2"
  364.   [(set (match_operand:DF 0 "register_operand" "=d")
  365.     (float:DF (match_operand:SI 1 "register_operand" "d")))]
  366.   "TARGET_C2"
  367.   "cvtw.d %1,%0")
  368.  
  369. (define_insn "floatdidf2"
  370.   [(set (match_operand:DF 0 "register_operand" "=d")
  371.     (float:DF (match_operand:DI 1 "register_operand" "d")))]
  372.   ""
  373.   "cvtl.d %1,%0")
  374.  
  375. ;; Float-to-fix conversion insns.
  376.  
  377. (define_insn "fix_truncsfsi2"
  378.   [(set (match_operand:SI 0 "register_operand" "=d")
  379.     (fix:SI (fix:SF (match_operand:SF 1 "register_operand" "d"))))]
  380.   ""
  381.   "cvts.w %1,%0")
  382.  
  383. (define_insn "fix_truncsfdi2"
  384.   [(set (match_operand:DI 0 "register_operand" "=d")
  385.     (fix:DI (fix:SF (match_operand:SF 1 "register_operand" "d"))))]
  386.   ""
  387.   "cvts.l %1,%0")
  388.  
  389. (define_insn "fix_truncdfsi2"
  390.   [(set (match_operand:SI 0 "register_operand" "=d")
  391.     (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "d"))))]
  392.   ""
  393.   "*
  394. {
  395.   if (TARGET_C2)
  396.     return \"cvtd.w %1,%0\";
  397.   return \"cvtd.l %1,%0\";
  398. }")
  399.  
  400. (define_insn "fix_truncdfdi2"
  401.   [(set (match_operand:DI 0 "register_operand" "=d")
  402.     (fix:DI (fix:DF (match_operand:DF 1 "register_operand" "d"))))]
  403.   ""
  404.   "cvtd.l %1,%0")
  405.  
  406. ;;- All kinds of add instructions.
  407.  
  408. (define_insn "adddf3"
  409.   [(set (match_operand:DF 0 "register_operand" "=d")
  410.     (plus:DF (match_operand:DF 1 "register_operand" "%0")
  411.          (match_operand:DF 2 "register_operand" "d")))]
  412.   ""
  413.   "add.d %2,%0")
  414.  
  415. (define_insn "addsf3"
  416.   [(set (match_operand:SF 0 "register_operand" "=d")
  417.     (plus:SF (match_operand:SF 1 "register_operand" "%0")
  418.          (match_operand:SF 2 "nonmemory_operand" "dF")))]
  419.   ""
  420.   "add.s %2,%0")
  421.  
  422. (define_insn "adddi3"
  423.   [(set (match_operand:DI 0 "register_operand" "=d")
  424.     (plus:DI (match_operand:DI 1 "register_operand" "%0")
  425.          (match_operand:DI 2 "register_operand" "d")))]
  426.   ""
  427.   "add.l %2,%0")
  428.  
  429. ;; special case of addsi3, needed to specify an A reg for the destination 
  430. ;; when the source is a sum involving FP or AP.
  431.  
  432. (define_insn ""
  433.   [(set (match_operand:SI 0 "register_operand" "=a")
  434.     (plus:SI (match_operand:SI 1 "register_operand" "%a")
  435.          (match_operand:SI 2 "immediate_operand" "i")))]
  436.   "operands[1] == frame_pointer_rtx || operands[1] == arg_pointer_rtx"
  437.   "ldea %a2(%1),%0")
  438.  
  439. (define_insn "addsi3"
  440.   [(set (match_operand:SI 0 "register_operand" "=d,a,a")
  441.     (plus:SI (match_operand:SI 1 "nonmemory_operand" "%0,0,a")
  442.          (match_operand:SI 2 "nonmemory_operand" "di,ri,i")))]
  443.   ""
  444.   "* switch (which_alternative) 
  445. {
  446.  case 0:
  447.  case 1: 
  448.    return \"add.w %2,%0\";
  449.  case 2:
  450.    if ((TARGET_C2 || A_REG_P (operands[0]))
  451.        && operands[1] != stack_pointer_rtx)
  452.      return \"ldea %a2(%1),%0\";
  453.    else
  454.      return \"mov %1,%0\;add.w %2,%0\";
  455. }")
  456.  
  457. (define_insn "addhi3"
  458.   [(set (match_operand:HI 0 "register_operand" "=d,a")
  459.     (plus:HI (match_operand:HI 1 "register_operand" "%0,0")
  460.          (match_operand:HI 2 "nonmemory_operand" "di,ai")))]
  461.   ""
  462.   "add.h %2,%0")
  463.  
  464. (define_insn "addqi3"
  465.   [(set (match_operand:QI 0 "register_operand" "=d")
  466.     (plus:QI (match_operand:QI 1 "register_operand" "%0")
  467.          (match_operand:QI 2 "register_operand" "d")))]
  468.   ""
  469.   "add.b %2,%0")
  470.  
  471. ;;- All kinds of subtract instructions.
  472.  
  473. (define_insn "subdf3"
  474.   [(set (match_operand:DF 0 "register_operand" "=d")
  475.     (minus:DF (match_operand:DF 1 "register_operand" "0")
  476.           (match_operand:DF 2 "register_operand" "d")))]
  477.   ""
  478.   "sub.d %2,%0")
  479.  
  480. (define_insn "subsf3"
  481.   [(set (match_operand:SF 0 "register_operand" "=d")
  482.     (minus:SF (match_operand:SF 1 "register_operand" "0")
  483.           (match_operand:SF 2 "nonmemory_operand" "dF")))]
  484.   ""
  485.   "sub.s %2,%0")
  486.  
  487. (define_insn "subdi3"
  488.   [(set (match_operand:DI 0 "register_operand" "=d")
  489.     (minus:DI (match_operand:DI 1 "register_operand" "0")
  490.           (match_operand:DI 2 "register_operand" "d")))]
  491.   ""
  492.   "sub.l %2,%0")
  493.  
  494. (define_insn "subsi3"
  495.   [(set (match_operand:SI 0 "register_operand" "=d,a")
  496.     (minus:SI (match_operand:SI 1 "register_operand" "0,0")
  497.           (match_operand:SI 2 "nonmemory_operand" "di,ai")))]
  498.   ""
  499.   "sub.w %2,%0")
  500.  
  501. (define_insn "subhi3"
  502.   [(set (match_operand:HI 0 "register_operand" "=d,a")
  503.     (minus:HI (match_operand:HI 1 "register_operand" "0,0")
  504.           (match_operand:HI 2 "nonmemory_operand" "di,ai")))]
  505.   ""
  506.   "sub.h %2,%0")
  507.  
  508. (define_insn "subqi3"
  509.   [(set (match_operand:QI 0 "register_operand" "=d")
  510.     (minus:QI (match_operand:QI 1 "register_operand" "0")
  511.           (match_operand:QI 2 "register_operand" "d")))]
  512.   ""
  513.   "sub.b %2,%0")
  514.  
  515. ;;- Multiply instructions.
  516.  
  517. (define_insn "muldf3"
  518.   [(set (match_operand:DF 0 "register_operand" "=d")
  519.     (mult:DF (match_operand:DF 1 "register_operand" "%0")
  520.          (match_operand:DF 2 "register_operand" "d")))]
  521.   ""
  522.   "mul.d %2,%0")
  523.  
  524. (define_insn "mulsf3"
  525.   [(set (match_operand:SF 0 "register_operand" "=d")
  526.     (mult:SF (match_operand:SF 1 "register_operand" "%0")
  527.          (match_operand:SF 2 "nonmemory_operand" "dF")))]
  528.   ""
  529.   "mul.s %2,%0")
  530.  
  531. (define_insn "muldi3"
  532.   [(set (match_operand:DI 0 "register_operand" "=d")
  533.     (mult:DI (match_operand:DI 1 "register_operand" "%0")
  534.          (match_operand:DI 2 "register_operand" "d")))]
  535.   ""
  536.   "mul.l %2,%0")
  537.  
  538. (define_insn "mulsi3"
  539.   [(set (match_operand:SI 0 "register_operand" "=d,a")
  540.     (mult:SI (match_operand:SI 1 "register_operand" "%0,0")
  541.          (match_operand:SI 2 "nonmemory_operand" "di,ai")))]
  542.   ""
  543.   "mul.w %2,%0")
  544.  
  545. (define_insn "mulhi3"
  546.   [(set (match_operand:HI 0 "register_operand" "=d,a")
  547.     (mult:HI (match_operand:HI 1 "register_operand" "%0,0")
  548.          (match_operand:HI 2 "nonmemory_operand" "di,ai")))]
  549.   ""
  550.   "mul.h %2,%0")
  551.  
  552. (define_insn "mulqi3"
  553.   [(set (match_operand:QI 0 "register_operand" "=d")
  554.     (mult:QI (match_operand:QI 1 "register_operand" "%0")
  555.          (match_operand:QI 2 "register_operand" "d")))]
  556.   ""
  557.   "mul.b %2,%0")
  558.  
  559. ;;- Divide instructions.
  560.  
  561. (define_insn "divdf3"
  562.   [(set (match_operand:DF 0 "register_operand" "=d")
  563.     (div:DF (match_operand:DF 1 "register_operand" "0")
  564.         (match_operand:DF 2 "register_operand" "d")))]
  565.   ""
  566.   "div.d %2,%0")
  567.  
  568. (define_insn "divsf3"
  569.   [(set (match_operand:SF 0 "register_operand" "=d")
  570.     (div:SF (match_operand:SF 1 "register_operand" "0")
  571.         (match_operand:SF 2 "nonmemory_operand" "dF")))]
  572.   ""
  573.   "div.s %2,%0")
  574.  
  575. (define_insn "divdi3"
  576.   [(set (match_operand:DI 0 "register_operand" "=d")
  577.     (div:DI (match_operand:DI 1 "register_operand" "0")
  578.         (match_operand:DI 2 "register_operand" "d")))]
  579.   ""
  580.   "div.l %2,%0")
  581.  
  582. (define_insn "udivdi3"
  583.   [(set (match_operand:DI 0 "register_operand" "=d")
  584.     (udiv:DI (match_operand:DI 1 "register_operand" "d")
  585.          (match_operand:DI 2 "register_operand" "d")))]
  586.   ""
  587.   "psh.l %2\;psh.l %1\;callq udiv64\;pop.l %0\;add.w #8,sp")
  588.  
  589. (define_insn "divsi3"
  590.   [(set (match_operand:SI 0 "register_operand" "=d,a")
  591.     (div:SI (match_operand:SI 1 "register_operand" "0,0")
  592.         (match_operand:SI 2 "nonmemory_operand" "di,ai")))]
  593.   ""
  594.   "div.w %2,%0")
  595.  
  596. (define_insn "divhi3"
  597.   [(set (match_operand:HI 0 "register_operand" "=d,a")
  598.     (div:HI (match_operand:HI 1 "register_operand" "0,0")
  599.         (match_operand:HI 2 "nonmemory_operand" "di,ai")))]
  600.   ""
  601.   "div.h %2,%0")
  602.  
  603. (define_insn "divqi3"
  604.   [(set (match_operand:QI 0 "register_operand" "=d")
  605.     (div:QI (match_operand:QI 1 "register_operand" "0")
  606.         (match_operand:QI 2 "register_operand" "d")))]
  607.   ""
  608.   "div.b %2,%0")
  609.  
  610. ;; - and, or, xor
  611.  
  612. (define_insn "anddi3"
  613.   [(set (match_operand:DI 0 "register_operand" "=d")
  614.     (and:DI (match_operand:DI 1 "register_operand" "%0")
  615.         (match_operand:DI 2 "register_operand" "d")))]
  616.   ""
  617.   "and %2,%0")
  618.  
  619. (define_insn "andsi3"
  620.   [(set (match_operand:SI 0 "register_operand" "=d,a")
  621.     (and:SI (match_operand:SI 1 "register_operand" "%0,0")
  622.         (match_operand:SI 2 "nonmemory_operand" "di,ai")))]
  623.   ""
  624.   "and %2,%0")
  625.  
  626. (define_insn "andhi3"
  627.   [(set (match_operand:HI 0 "register_operand" "=d,a")
  628.     (and:HI (match_operand:HI 1 "register_operand" "%0,0")
  629.         (match_operand:HI 2 "nonmemory_operand" "di,ai")))]
  630.   ""
  631.   "and %2,%0")
  632.  
  633. (define_insn "andqi3"
  634.   [(set (match_operand:QI 0 "register_operand" "=d,a")
  635.     (and:QI (match_operand:QI 1 "register_operand" "%0,0")
  636.         (match_operand:QI 2 "nonmemory_operand" "di,ai")))]
  637.   ""
  638.   "and %2,%0")
  639.  
  640. ;;- Bit set instructions.
  641.  
  642. (define_insn "iordi3"
  643.   [(set (match_operand:DI 0 "register_operand" "=d")
  644.     (ior:DI (match_operand:DI 1 "register_operand" "%0")
  645.         (match_operand:DI 2 "register_operand" "d")))]
  646.   ""
  647.   "or %2,%0")
  648.  
  649. (define_insn "iorsi3"
  650.   [(set (match_operand:SI 0 "register_operand" "=d,a")
  651.     (ior:SI (match_operand:SI 1 "register_operand" "%0,0")
  652.         (match_operand:SI 2 "nonmemory_operand" "di,ai")))]
  653.   ""
  654.   "or %2,%0")
  655.  
  656. (define_insn "iorhi3"
  657.   [(set (match_operand:HI 0 "register_operand" "=d,a")
  658.     (ior:HI (match_operand:HI 1 "register_operand" "%0,0")
  659.         (match_operand:HI 2 "nonmemory_operand" "di,ai")))]
  660.   ""
  661.   "or %2,%0")
  662.  
  663. (define_insn "iorqi3"
  664.   [(set (match_operand:QI 0 "register_operand" "=d,a")
  665.     (ior:QI (match_operand:QI 1 "register_operand" "%0,0")
  666.         (match_operand:QI 2 "nonmemory_operand" "di,ai")))]
  667.   ""
  668.   "or %2,%0")
  669.  
  670. ;;- xor instructions.
  671.  
  672. (define_insn "xordi3"
  673.   [(set (match_operand:DI 0 "register_operand" "=d")
  674.     (xor:DI (match_operand:DI 1 "register_operand" "%0")
  675.         (match_operand:DI 2 "register_operand" "d")))]
  676.   ""
  677.   "xor %2,%0")
  678.  
  679. (define_insn "xorsi3"
  680.   [(set (match_operand:SI 0 "register_operand" "=d,a")
  681.     (xor:SI (match_operand:SI 1 "register_operand" "%0,0")
  682.         (match_operand:SI 2 "nonmemory_operand" "di,ai")))]
  683.   ""
  684.   "xor %2,%0")
  685.  
  686. (define_insn "xorhi3"
  687.   [(set (match_operand:HI 0 "register_operand" "=d,a")
  688.     (xor:HI (match_operand:HI 1 "register_operand" "%0,0")
  689.         (match_operand:HI 2 "nonmemory_operand" "di,ai")))]
  690.   ""
  691.   "xor %2,%0")
  692.  
  693. (define_insn "xorqi3"
  694.   [(set (match_operand:QI 0 "register_operand" "=d,a")
  695.     (xor:QI (match_operand:QI 1 "register_operand" "%0,0")
  696.         (match_operand:QI 2 "nonmemory_operand" "di,ai")))]
  697.   ""
  698.   "xor %2,%0")
  699.  
  700. (define_insn "negdf2"
  701.   [(set (match_operand:DF 0 "register_operand" "=d")
  702.     (neg:DF (match_operand:DF 1 "register_operand" "d")))]
  703.   ""
  704.   "neg.d %1,%0")
  705.  
  706. (define_insn "negsf2"
  707.   [(set (match_operand:SF 0 "register_operand" "=d")
  708.     (neg:SF (match_operand:SF 1 "register_operand" "d")))]
  709.   ""
  710.   "neg.s %1,%0")
  711.  
  712. (define_insn "negdi2"
  713.   [(set (match_operand:DI 0 "register_operand" "=d")
  714.     (neg:DI (match_operand:DI 1 "register_operand" "d")))]
  715.   ""
  716.   "neg.l %1,%0")
  717.  
  718. (define_insn "negsi2"
  719.   [(set (match_operand:SI 0 "register_operand" "=d,a")
  720.     (neg:SI (match_operand:SI 1 "register_operand" "d,a")))]
  721.   ""
  722.   "neg.w %1,%0")
  723.  
  724. (define_insn "neghi2"
  725.   [(set (match_operand:HI 0 "register_operand" "=d,a")
  726.     (neg:HI (match_operand:HI 1 "register_operand" "d,a")))]
  727.   ""
  728.   "neg.h %1,%0")
  729.  
  730. (define_insn "negqi2"
  731.   [(set (match_operand:QI 0 "register_operand" "=d")
  732.     (neg:QI (match_operand:QI 1 "register_operand" "d")))]
  733.   ""
  734.   "neg.b %1,%0")
  735.  
  736. (define_insn "one_cmpldi2"
  737.   [(set (match_operand:DI 0 "register_operand" "=d")
  738.     (not:DI (match_operand:DI 1 "register_operand" "d")))]
  739.   ""
  740.   "not %1,%0")
  741.  
  742. (define_insn "one_cmplsi2"
  743.   [(set (match_operand:SI 0 "register_operand" "=d,a")
  744.     (not:SI (match_operand:SI 1 "register_operand" "d,a")))]
  745.   ""
  746.   "not %1,%0")
  747.  
  748. (define_insn "one_cmplhi2"
  749.   [(set (match_operand:HI 0 "register_operand" "=d,a")
  750.     (not:HI (match_operand:HI 1 "register_operand" "d,a")))]
  751.   ""
  752.   "not %1,%0")
  753.  
  754. (define_insn "one_cmplqi2"
  755.   [(set (match_operand:QI 0 "register_operand" "=d,a")
  756.     (not:QI (match_operand:QI 1 "register_operand" "d,a")))]
  757.   ""
  758.   "not %1,%0")
  759.  
  760. ;;- shifts
  761. ;;
  762. ;; Convex shift instructions are unsigned.
  763. ;; To make signed right shifts:
  764. ;; for SImode, sign extend to DImode and shift, works for 0..32
  765. ;; for DImode, shift and then extend the sign, works for 0..63
  766. ;;
  767. ;; It is very sad that DImode right shift 64 fails, but I don't see
  768. ;; any reasonable way to handle it.  ANSI only requires up to 63.
  769.  
  770. (define_insn ""
  771.   [(set (match_operand:SI 0 "register_operand" "=r")
  772.     (ashift:SI (match_operand:SI 1 "register_operand" "0")
  773.            (match_operand:SI 2 "immediate_operand" "i")))]
  774.   "INTVAL (operands[2]) >= 0"
  775.   "*
  776. {
  777.   if (operands[2] == const1_rtx)
  778.     return \"add.w %0,%0\";
  779.   else if (TARGET_C2 && S_REG_P (operands[0]))
  780.     return \"shf.w %2,%0\";
  781.   else
  782.     return \"shf %2,%0\";
  783. }")
  784.  
  785. (define_insn "ashlsi3"
  786.   [(set (match_operand:SI 0 "register_operand" "=d")
  787.     (ashift:SI (match_operand:SI 1 "register_operand" "0")
  788.            (match_operand:SI 2 "nonmemory_operand" "di")))]
  789.   ""
  790.   "*
  791. {
  792.   if (operands[2] == const1_rtx)
  793.     return \"add.w %0,%0\";
  794.   else if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 0)
  795.     return TARGET_C2 ? \"shf.w %2,%0\" : \"shf %2,%0\";
  796.   else
  797.     return \"cvtw.l %0,%0\;shf %2,%0\";
  798. }")
  799.  
  800. (define_expand "ashrsi3"
  801.   [(set (match_operand:SI 0 "register_operand" "=d")
  802.     (ashift:SI (match_operand:SI 1 "register_operand" "0")
  803.            (match_operand:SI 2 "nonmemory_operand" "di")))]
  804.   ""
  805.   "operands[2] = negate_rtx (SImode, operands[2]);")
  806.  
  807. (define_insn "lshlsi3"
  808.   [(set (match_operand:SI 0 "register_operand" "=d,a")
  809.     (lshift:SI (match_operand:SI 1 "register_operand" "0,0")
  810.            (match_operand:SI 2 "nonmemory_operand" "di,ai")))]
  811.   ""
  812.   "*
  813. {
  814.   if (operands[2] == const1_rtx)
  815.     return \"add.w %0,%0\";
  816.   if (S_REG_P (operands[0]))
  817.     {
  818.       if (TARGET_C2)
  819.     return \"shf.w %2,%0\";
  820.       else if (GET_CODE (operands[2]) == CONST_INT
  821.            && INTVAL (operands[2]) >= 0)
  822.         return \"shf %2,%0\";
  823.       else
  824.         return \"ld.u #0,%0\;shf %2,%0\";
  825.     }
  826.   return \"shf %2,%0\";
  827. }")
  828.  
  829. (define_expand "lshrsi3"
  830.   [(set (match_operand:SI 0 "register_operand" "=d")
  831.     (lshift:SI (match_operand:SI 1 "register_operand" "0")
  832.            (match_operand:SI 2 "nonmemory_operand" "di")))]
  833.   ""
  834.   "operands[2] = negate_rtx (SImode, operands[2]);")
  835.  
  836. ;; signed  a >> b  is
  837. ;;     ((a >> b) ^ signbit) - signbit
  838. ;; where signbit is (1 << 63) >> b
  839.  
  840. (define_expand "ashldi3"
  841.   [(match_operand:DI 0 "register_operand" "=d")
  842.    (match_operand:DI 1 "register_operand" "0")
  843.    (match_operand:SI 2 "nonmemory_operand" "di")
  844.    (match_dup 3)]
  845.   ""
  846.   "
  847. {
  848.   if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 0)
  849.     emit_insn (gen_rtx (SET, VOIDmode, operands[0],
  850.             gen_rtx (LSHIFT, DImode, operands[1], operands[2])));
  851.   else if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
  852.     {
  853.       int rshift = - INTVAL (operands[2]);
  854.       operands[3] = force_reg
  855.     (DImode,
  856.      immed_double_const (1 << (63 - rshift), 1 << (31 - rshift), DImode));
  857.       emit_insn (gen_rtx (SET, VOIDmode, operands[0],
  858.               gen_rtx (LSHIFT, DImode, operands[1], operands[2])));
  859.       emit_insn (gen_rtx (SET, VOIDmode, operands[0],
  860.               gen_rtx (XOR, DImode, operands[0], operands[3])));
  861.       emit_insn (gen_rtx (SET, VOIDmode, operands[0],
  862.               gen_rtx (MINUS, DImode, operands[0], operands[3])));
  863.     }
  864.   else
  865.     {
  866.       operands[3] =
  867.     force_reg (DImode, immed_double_const (0, 1 << 31, DImode));
  868.       emit_insn (gen_rtx (SET, VOIDmode, operands[0],
  869.               gen_rtx (LSHIFT, DImode, operands[1], operands[2])));
  870.       emit_insn (gen_rtx (SET, VOIDmode, operands[3],
  871.               gen_rtx (LSHIFT, DImode, operands[3], operands[2])));
  872.       emit_insn (gen_rtx (SET, VOIDmode, operands[0],
  873.               gen_rtx (XOR, DImode, operands[0], operands[3])));
  874.       emit_insn (gen_rtx (SET, VOIDmode, operands[0],
  875.               gen_rtx (MINUS, DImode, operands[0], operands[3])));
  876.   }
  877.   DONE;
  878. }")
  879.  
  880. (define_expand "ashrdi3"
  881.   [(match_operand:DI 0 "register_operand" "=d")
  882.    (match_operand:DI 1 "register_operand" "0")
  883.    (match_operand:SI 2 "nonmemory_operand" "di")]
  884.   ""
  885.   "
  886. {
  887.   emit_insn (gen_ashldi3 (operands[0], operands[1],
  888.               negate_rtx (SImode, operands[2])));
  889.   DONE;        
  890. }")
  891.  
  892. (define_insn "lshldi3"
  893.   [(set (match_operand:DI 0 "register_operand" "=d")
  894.     (lshift:DI (match_operand:DI 1 "register_operand" "0")
  895.            (match_operand:SI 2 "nonmemory_operand" "di")))]
  896.   ""
  897.   "shf %2,%0")
  898.  
  899. (define_expand "lshrdi3"
  900.   [(set (match_operand:DI 0 "register_operand" "=d")
  901.     (lshift:DI (match_operand:DI 1 "register_operand" "0")
  902.            (match_operand:SI 2 "nonmemory_operand" "di")))]
  903.   ""
  904.   "operands[2] = negate_rtx (SImode, operands[2]);")
  905.  
  906. ;; __builtin instructions
  907.  
  908. (define_insn "sqrtdf2"
  909.   [(set (match_operand:DF 0 "register_operand" "=d")
  910.     (sqrt:DF (match_operand:DF 1 "register_operand" "0")))]
  911.   "TARGET_C2"
  912.   "sqrt.d %0")
  913.  
  914. (define_insn "sqrtsf2"
  915.   [(set (match_operand:SF 0 "register_operand" "=d")
  916.     (sqrt:SF (match_operand:SF 1 "register_operand" "0")))]
  917.   "TARGET_C2"
  918.   "sqrt.s %0")
  919.  
  920. (define_insn ""
  921.   [(set (match_operand:SI 0 "register_operand" "=d")
  922.     (minus:SI (ffs:SI (match_operand:SI 1 "register_operand" "d"))
  923.           (const_int 1)))]
  924.   ""
  925.   "tzc %1,%0\;le.w #32,%0\;jbrs.f .+6\;ld.w #-1,%0")
  926.  
  927. (define_expand "ffssi2"
  928.   [(set (match_operand:SI 0 "register_operand" "=d")
  929.     (minus:SI (ffs:SI (match_operand:SI 1 "register_operand" "d"))
  930.           (const_int 1)))
  931.    (set (match_dup 0)
  932.     (plus:SI (match_dup 0)
  933.          (const_int 1)))]
  934.   ""
  935.   "")
  936.  
  937. (define_insn "abssf2"
  938.   [(set (match_operand:SF 0 "register_operand" "=d")
  939.     (abs:SF (match_operand:SF 1 "register_operand" "0")))]
  940.   ""
  941.   "and #0x7fffffff,%0")
  942.  
  943. (define_expand "absdf2"
  944.   [(set (subreg:DI (match_operand:DF 0 "register_operand" "=d") 0)
  945.     (and:DI (subreg:DI (match_operand:DF 1 "register_operand" "d") 0)
  946.         (match_dup 2)))]
  947.   ""
  948.   "operands[2] = force_reg (DImode,
  949.                 immed_double_const (-1, 0x7fffffff, DImode));")
  950.  
  951. (define_insn "jump"
  952.   [(set (pc)
  953.     (label_ref (match_operand 0 "" "")))]
  954.   ""
  955.   "jbr %l0")
  956.  
  957. (define_insn "beq"
  958.   [(set (pc)
  959.     (if_then_else (eq (cc0)
  960.               (const_int 0))
  961.               (label_ref (match_operand 0 "" ""))
  962.               (pc)))]
  963.   ""
  964.   "* return gen_cmp (operands[0], \"eq\", 't'); ")
  965.  
  966. (define_insn "bne"
  967.   [(set (pc)
  968.     (if_then_else (ne (cc0)
  969.               (const_int 0))
  970.               (label_ref (match_operand 0 "" ""))
  971.               (pc)))]
  972.   ""
  973.   "* return gen_cmp (operands[0], \"eq\", 'f'); ")
  974.  
  975. (define_insn "bgt"
  976.   [(set (pc)
  977.     (if_then_else (gt (cc0)
  978.               (const_int 0))
  979.               (label_ref (match_operand 0 "" ""))
  980.               (pc)))]
  981.   ""
  982.   "* return gen_cmp (operands[0], \"le\", 'f'); ")
  983.  
  984. (define_insn "bgtu"
  985.   [(set (pc)
  986.     (if_then_else (gtu (cc0)
  987.                (const_int 0))
  988.               (label_ref (match_operand 0 "" ""))
  989.               (pc)))]
  990.   ""
  991.   "* return gen_cmp (operands[0], \"leu\", 'f'); ")
  992.  
  993. (define_insn "blt"
  994.   [(set (pc)
  995.     (if_then_else (lt (cc0)
  996.               (const_int 0))
  997.               (label_ref (match_operand 0 "" ""))
  998.               (pc)))]
  999.   ""
  1000.   "* return gen_cmp (operands[0], \"lt\", 't'); ")
  1001.  
  1002. (define_insn "bltu"
  1003.   [(set (pc)
  1004.     (if_then_else (ltu (cc0)
  1005.                (const_int 0))
  1006.               (label_ref (match_operand 0 "" ""))
  1007.               (pc)))]
  1008.   ""
  1009.   "* return gen_cmp (operands[0], \"ltu\", 't'); ")
  1010.  
  1011. (define_insn "bge"
  1012.   [(set (pc)
  1013.     (if_then_else (ge (cc0)
  1014.               (const_int 0))
  1015.               (label_ref (match_operand 0 "" ""))
  1016.               (pc)))]
  1017.   ""
  1018.   "* return gen_cmp (operands[0], \"lt\", 'f'); ")
  1019.  
  1020. (define_insn "bgeu"
  1021.   [(set (pc)
  1022.     (if_then_else (geu (cc0)
  1023.                (const_int 0))
  1024.               (label_ref (match_operand 0 "" ""))
  1025.               (pc)))]
  1026.   ""
  1027.   "* return gen_cmp (operands[0], \"ltu\", 'f'); ")
  1028.  
  1029. (define_insn "ble"
  1030.   [(set (pc)
  1031.     (if_then_else (le (cc0)
  1032.               (const_int 0))
  1033.               (label_ref (match_operand 0 "" ""))
  1034.               (pc)))]
  1035.   ""
  1036.   "* return gen_cmp (operands[0], \"le\", 't'); ")
  1037.  
  1038. (define_insn "bleu"
  1039.   [(set (pc)
  1040.     (if_then_else (leu (cc0)
  1041.                (const_int 0))
  1042.               (label_ref (match_operand 0 "" ""))
  1043.               (pc)))]
  1044.   ""
  1045.   "* return gen_cmp (operands[0], \"leu\", 't'); ")
  1046.  
  1047. (define_insn ""
  1048.   [(set (pc)
  1049.     (if_then_else (eq (cc0)
  1050.               (const_int 0))
  1051.               (pc)
  1052.               (label_ref (match_operand 0 "" ""))))]
  1053.   ""
  1054.   "* return gen_cmp (operands[0], \"eq\", 'f'); ")
  1055.  
  1056. (define_insn ""
  1057.   [(set (pc)
  1058.     (if_then_else (ne (cc0)
  1059.               (const_int 0))
  1060.               (pc)
  1061.               (label_ref (match_operand 0 "" ""))))]
  1062.   ""
  1063.   "* return gen_cmp (operands[0], \"eq\", 't'); ")
  1064.  
  1065. (define_insn ""
  1066.   [(set (pc)
  1067.     (if_then_else (gt (cc0)
  1068.               (const_int 0))
  1069.               (pc)
  1070.               (label_ref (match_operand 0 "" ""))))]
  1071.   ""
  1072.   "* return gen_cmp (operands[0], \"le\", 't'); ")
  1073.  
  1074. (define_insn ""
  1075.   [(set (pc)
  1076.     (if_then_else (gtu (cc0)
  1077.                (const_int 0))
  1078.               (pc)
  1079.               (label_ref (match_operand 0 "" ""))))]
  1080.   ""
  1081.   "* return gen_cmp (operands[0], \"leu\", 't'); ")
  1082.  
  1083. (define_insn ""
  1084.   [(set (pc)
  1085.     (if_then_else (lt (cc0)
  1086.               (const_int 0))
  1087.               (pc)
  1088.               (label_ref (match_operand 0 "" ""))))]
  1089.   ""
  1090.   "* return gen_cmp (operands[0], \"lt\", 'f'); ")
  1091.  
  1092. (define_insn ""
  1093.   [(set (pc)
  1094.     (if_then_else (ltu (cc0)
  1095.                (const_int 0))
  1096.               (pc)
  1097.               (label_ref (match_operand 0 "" ""))))]
  1098.   ""
  1099.   "* return gen_cmp (operands[0], \"ltu\", 'f'); ")
  1100.  
  1101. (define_insn ""
  1102.   [(set (pc)
  1103.     (if_then_else (ge (cc0)
  1104.               (const_int 0))
  1105.               (pc)
  1106.               (label_ref (match_operand 0 "" ""))))]
  1107.   ""
  1108.   "* return gen_cmp (operands[0], \"lt\", 't'); ")
  1109.  
  1110. (define_insn ""
  1111.   [(set (pc)
  1112.     (if_then_else (geu (cc0)
  1113.                (const_int 0))
  1114.               (pc)
  1115.               (label_ref (match_operand 0 "" ""))))]
  1116.   ""
  1117.   "* return gen_cmp (operands[0], \"ltu\", 't'); ")
  1118.  
  1119. (define_insn ""
  1120.   [(set (pc)
  1121.     (if_then_else (le (cc0)
  1122.               (const_int 0))
  1123.               (pc)
  1124.               (label_ref (match_operand 0 "" ""))))]
  1125.   ""
  1126.   "* return gen_cmp (operands[0], \"le\", 'f'); ")
  1127.  
  1128. (define_insn ""
  1129.   [(set (pc)
  1130.     (if_then_else (leu (cc0)
  1131.                (const_int 0))
  1132.               (pc)
  1133.               (label_ref (match_operand 0 "" ""))))]
  1134.   ""
  1135.   "* return gen_cmp (operands[0], \"leu\", 'f'); ")
  1136.  
  1137. ;;  - Calls
  1138. ;;
  1139. ;; arg count word may be omitted to save a push and let gcc try to
  1140. ;; combine the arg list pop.  RETURN_POPS_ARGS from tm.h decides this.
  1141.  
  1142. (define_insn "call"
  1143.   [(call (match_operand:QI 0 "general_operand" "g")
  1144.      (match_operand:SI 1 "general_operand" "g"))]
  1145.   ""
  1146.   "*
  1147. {
  1148.   if (! RETURN_POPS_ARGS (ignoreme)) 
  1149.     {
  1150.       if (operands[1] == const0_rtx)
  1151.     return \"calls %0\";
  1152.       if (! reg_mentioned_p (arg_pointer_rtx, operands[0]))
  1153.     return \"mov sp,ap\;calls %0\;ld.w 12(fp),ap\";
  1154.       operands[0] = XEXP (operands[0], 0);
  1155.       return \"ld.w %0,a1\;mov sp,ap\;calls (a1)\;ld.w 12(fp),ap\";
  1156.     }
  1157.   operands[1] = gen_rtx (CONST_INT, VOIDmode, (INTVAL (operands[1]) + 3)/ 4);
  1158.   if (! reg_mentioned_p (arg_pointer_rtx, operands[0]))
  1159.     return \"mov sp,ap\;pshea %a1\;calls %0\;ld.w 12(fp),ap\;add.w #4*%a1+4,sp\";
  1160.   operands[0] = XEXP (operands[0], 0);
  1161.   return \"ld.w %0,a1\;mov sp,ap\;pshea %a1\;calls (a1)\;ld.w 12(fp),ap\;add.w #4*%a1+4,sp\";
  1162. }")
  1163.  
  1164. (define_insn "call_value"
  1165.   [(set (match_operand 0 "" "=g")
  1166.     (call (match_operand:QI 1 "general_operand" "g")
  1167.           (match_operand:SI 2 "general_operand" "g")))]
  1168.   ""
  1169.   "*
  1170. {
  1171.   if (! RETURN_POPS_ARGS (ignoreme)) 
  1172.     {
  1173.       if (operands[2] == const0_rtx)
  1174.     return \"calls %1\";
  1175.       if (! reg_mentioned_p (arg_pointer_rtx, operands[1]))
  1176.     return \"mov sp,ap\;calls %1\;ld.w 12(fp),ap\";
  1177.       operands[1] = XEXP (operands[1], 0);
  1178.       return \"ld.w %1,a1\;mov sp,ap\;calls (a1)\;ld.w 12(fp),ap\";
  1179.     }
  1180.   operands[2] = gen_rtx (CONST_INT, VOIDmode, (INTVAL (operands[2]) + 3) / 4);
  1181.   if (! reg_mentioned_p (arg_pointer_rtx, operands[1]))
  1182.     return \"mov sp,ap\;pshea %a2\;calls %1\;ld.w 12(fp),ap\;add.w #4*%a2+4,sp\";
  1183.   operands[1] = XEXP (operands[1], 0);
  1184.   return \"ld.w %1,a1\;mov sp,ap\;pshea %a2\;calls (a1)\;ld.w 12(fp),ap\;add.w #4*%a2+4,sp\";
  1185. }")
  1186.  
  1187. (define_insn "return"
  1188.   [(return)]
  1189.   ""
  1190.   "rtn")
  1191.  
  1192. (define_insn "nop"
  1193.   [(const_int 0)]
  1194.   ""
  1195.   "nop")
  1196.  
  1197. (define_insn "tablejump"
  1198.   [(set (pc) (match_operand:SI 0 "address_operand" "p"))
  1199.    (use (label_ref (match_operand 1 "" "")))]
  1200.   ""
  1201.   "jmp %a0")
  1202.  
  1203. ;; - fix up the code generated for bit field tests
  1204.  
  1205. ;; cc0 = (x >> k1) & k2  -->  cc0 = x & (k2 << k1)
  1206. ;; cc0 = (x << k1) & k2  -->  cc0 = x & (k2 >> k1)  
  1207. ;; provided k2 and (k2 << k1) don't include the sign bit
  1208.  
  1209. (define_peephole
  1210.   [(set (match_operand:SI 0 "register_operand" "r")
  1211.     (lshift:SI (match_dup 0)
  1212.            (match_operand 1 "immediate_operand" "i")))
  1213.    (set (match_dup 0)
  1214.     (and:SI (match_dup 0)
  1215.         (match_operand 2 "immediate_operand" "i")))
  1216.    (set (cc0) (match_dup 0))]
  1217.   "dead_or_set_p (insn, operands[0])
  1218.    && GET_CODE (operands[1]) == CONST_INT
  1219.    && GET_CODE (operands[2]) == CONST_INT
  1220.    && INTVAL (operands[2]) >= 0
  1221.    && (INTVAL (operands[2]) << INTVAL (operands[1])) >= 0"
  1222.   "*
  1223. {
  1224.   operands[2] = gen_rtx (CONST_INT, VOIDmode, 
  1225.              INTVAL (operands[2]) >> INTVAL (operands[1]));
  1226.   output_asm_insn (\"and %2,%0\", operands);
  1227.   return set_cmp (operands[0], const0_rtx, 'w');
  1228. }")
  1229.  
  1230. ;; same as above where x is (y & 0xff...) caused by a zero extend
  1231.  
  1232. (define_peephole
  1233.   [(set (match_operand:SI 0 "register_operand" "r")
  1234.     (zero_extend:SI (match_operand 1 "register_operand" "0")))
  1235.    (set (match_dup 0)
  1236.     (lshift:SI (match_dup 0)
  1237.            (match_operand 2 "immediate_operand" "i")))
  1238.    (set (match_dup 0)
  1239.     (and:SI (match_dup 0)
  1240.         (match_operand 3 "immediate_operand" "i")))
  1241.    (set (cc0) (match_dup 0))]
  1242.   "dead_or_set_p (insn, operands[0])
  1243.    && REGNO (operands[0]) == REGNO (operands[1])
  1244.    && GET_CODE (operands[2]) == CONST_INT
  1245.    && GET_CODE (operands[3]) == CONST_INT
  1246.    && (INTVAL (operands[3]) << INTVAL (operands[2])) >= 0"
  1247.   "*
  1248. {
  1249.   operands[3] = gen_rtx (CONST_INT, VOIDmode, 
  1250.              (INTVAL (operands[3]) >> INTVAL (operands[2])) &
  1251.              ~((-1) << GET_MODE_BITSIZE (GET_MODE (operands[1]))));
  1252.   output_asm_insn (\"and %3,%0\", operands);
  1253.   return set_cmp (operands[0], const0_rtx, 'w');
  1254. }")
  1255.  
  1256. ;;- Local variables:
  1257. ;;- mode:emacs-lisp
  1258. ;;- comment-start: ";;- "
  1259. ;;- eval: (set-syntax-table (copy-sequence (syntax-table)))
  1260. ;;- eval: (modify-syntax-entry ?[ "(]")
  1261. ;;- eval: (modify-syntax-entry ?] ")[")
  1262. ;;- eval: (modify-syntax-entry ?{ "(}")
  1263. ;;- eval: (modify-syntax-entry ?} "){")
  1264. ;;- End:
  1265.  
  1266.